package org.scboy.common.loads;

import org.apache.dubbo.config.annotation.DubboReference;
import org.scboy.coobi.sql.Coobi;
import org.scboy.coobi.sql.factory.EntityFactory;
import org.scboy.dbms.api.IDynamicManager;
import org.scboy.utils.caches.dbms.entity.DesignEntity;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableCaching
@AutoConfigureAfter(value = {Coobi.class,EntityFactory.class})
public class LoadDynamic {

	@DubboReference
	IDynamicManager manager;

	@Cacheable(value="DBMS_SERVICE_DESIGN",key="#appName + '['+#code+']'",unless="#result == null")
	public DesignEntity getService(String code,String appName){
		return manager.getServiceDesign(code,appName);
	}

	@Cacheable(value="DBMS_REQUEST_DESIGN",key="#appName + '['+#code+']'",unless="#result == null")
	public DesignEntity getRequest(String code,String appName){
		return manager.getRequestDesign(code,appName);
	}
}
